package com.xlh.Utils;

import android.util.Log;

import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by fang on 2017-11-14.
 */

public class ProtocolParser {

        //CMDS指令转HTML点击抱歉
        public static String CmdUrlToHtml(String s) throws ArrayIndexOutOfBoundsException{

            //[u:cmds:enter dong][s:20]点我[2;37;0m。
            //\[u:cmds:(.*)\]\[s:(.*)\](.+?)(?:\[2;37;0m)
            Pattern pet2 = Pattern.compile(MudProtocol.ESA+"\\[u:cmds:(.+?)\\]"+MudProtocol.ESA+"\\[s:(.+?)\\](.+?)"+MudProtocol.ESA+"(?:\\[2;37;0m){1}");
            Matcher match2 = pet2.matcher(s);
            while (match2.find()) {
                s=s.replace(match2.group(0),String.format("<wzfont size='%s' cmds='%s'>%s</wzfont>",match2.group(2),match2.group(1),match2.group(3)));
               // Log.i("WZURL",match2.group(1));

            }
            return s;
        }




}
